<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Champion;
use App\King;
use App\Master;
class ChampionController extends Controller
{
    //
    public function index(King $king)
    {
        $kings = King::orderBy('ement', 'desc')->get();
        return view('champion/champion',compact('kings'));
    }
    //修改页面
    public function admin(King $king)
    {
        return view('admin/index',compact('king'));
    }
    //
    public function update(King $king)
    {
        //验证
        $this->validate(request(), [
            'name' => 'required',
            'ement' => 'required',
        ]);
        //逻辑
        $king->name = request("name");
        $king->ement = request("ement");
        $king->save();
        //渲染
        return redirect('/champion');
    }
    //
//    public function master(Master $master)
//    {
//        $masters = Master::orderBy('created_at', 'desc')->get();
//        return view('champion/champion',compact('master'));
//    }

}
